<?php
if(!class_exists('MAIN_Controller_Action')) Zend_Loader :: loadClass('MAIN_Controller_ActionFront');
class Front_PreauthorizeController extends MAIN_Controller_ActionFront{
	public function preauthorizeAction() {
		$view = $this->_getView();
		$generic = $this->getGeneric();
		$data = $generic->getFund();
		$view->assign("data",$data);
		$view->output('preauthorize/preauthorize.tpl');
    }
    public function loadtplAction(){
    	$params   = $this->getParams();
    	$view = $this->_getView();
    	$view->output('preauthorize/'.$params['tpl'].'.tpl');
    }
    public function getpreauthbyfundAction(){
    	$params   = $this->getParams();
    	$generic = $this->getGeneric();
    	$view = $this->_getView();
    	$data = $generic->getpreauthbyfund($params);
    	$view->assign("data",$data);
    	$data['htmls'] = $view->outputhtml('ajax/_view_preauth_list.tpl');
    	$this->_helper->json($data);
    }
    public function preauthdetailAction(){
    	$params   = $this->getParams();
    	$generic = $this->getGeneric();
    	$view = $this->_getView();
    	$today = getToday();
    	$preauthId = $generic->getPreauthId();
    	$policyData = $generic->getPolicyById($params['policy_id']);
    	$paInfo = $generic->getPaInfo($params['policy_id']);
    	if($policyData['customer_type_desc'] == 'PA'){
    		$paClaimData = $generic->getPaClaim($params['policy_id']);
    		$tpl = 'preauthorize/pa_detail.tpl';
    	}
    	else{
    		$paClaimData = $generic->getPaClaimOpd($params['policy_id']);
    		$erClaimData = $generic->getErClaim($params['policy_no']);
    		$PlanData = $generic->getPlan2catByPlanId($policyData['plan_id']);
    		$view->assign("erClaimData",$erClaimData);
    		$view->assign("PlanData",$PlanData);
    		$tpl = 'preauthorize/health_detail.tpl';
    	}
    	//_print($policyData['plan_id']);
    	$view->assign("policy_id",$params['policy_id']);
    	$view->assign("today",$today);
    	$view->assign("preauthId",$preauthId);
    	$view->assign("policyData",$policyData);
    	$view->assign("paInfo",$paInfo);
    	$view->assign("paClaimData",$paClaimData);
    	$view->assign("title",'Pre-authorize');
    	$view->output($tpl);
    }
    public function getpreauthconfirmAction(){
    	$params   = $this->getParams();
    	$view = $this->_getView();
    	$data['today']	= date("Y-m-d H:i:s");
    	$data['policy_id'] = $params['policy_id'];
    	$data['policy_no'] = $params['policy_no'];
    	$data['card_no'] = $params['card_no'];
    	$data['member_name'] = $params['member_name'];
    	$data['member_lname'] = $params['member_lname'];
    	$data['nat_id'] = $params['nat_id'];
    	$data['preauth_id'] = $params['preauth_id'];
    	$data['customer_type_desc'] = $params['customer_type_desc'];
    	$view->assign("data",$data);
    	$data['htmls'] = $view->outputhtml('ajax/_view_preauth_detail_confirm.tpl');
    	$this->_helper->json($data);
    }
    public function insertpreauthAction(){
    	$params = $this->getParams();
    	$generic = $this->getGeneric();
    	$generic->insertPreauth($params);
    }
    public function seachidcardAction(){
    	$view = $this->_getView();
    	$generic = $this->getGeneric();
    	$data = $generic->getFund();
    	$view->assign("data",$data);
    	$view->output('preauthorize/search_idcard.tpl');
    }
    public function getpreauthbyidcardAction(){
    	$params   = $this->getParams();
    	$generic = $this->getGeneric();
    	$view = $this->_getView();
    	$data = $generic->getpreauthbyidcard($params);
    	$view->assign("data",$data);
    	$data['htmls'] = $view->outputhtml('ajax/_view_preauth_list.tpl');
    	$this->_helper->json($data);
    }
}
?>